﻿/**
 * @file mainwindow.cpp
 * @author huangxb
 * @email 18228033207@163.com
 * @date 2024.04.04
 * @license MIT License
 * @brief 主窗口.
 *
 * @htmlonly
 * <span style="font-weight: bold">History</span>
 * @endhtmlonly
 * Version|Auther|Date|Describe
 * ------|----|------|--------
 * V1.0|huangxb|2024.04.04|创建
 */

/* 自定义头文件 */
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "table/coverwidgetitemtableview.h"
#include "tree/treeviewwithcustomwidget.h"
#include "graphics-view/paintboardwidget.h"
#include "tab/styledtabwidget.h"
#include "viewdatacontroller.h"
#include "tableviewdatarefnodeadapter.h"
#include "button/buttoncontainerwidget.h"
#include "lineedit/lineeditcontainerwidget.h"

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
    , m_spViewDataController(std::make_shared<CViewDataController>())
    , m_spTableViewDataRefNodeAdapter(std::make_shared<CTableViewDataRefNodeAdapter>())
{
    ui->setupUi(this);
}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::on_m_tableView_menuAction_triggered()
{
    CCoverWidgetItemTableView *pWidget = new CCoverWidgetItemTableView(this);
    setCentralWidget(pWidget);

    m_spViewDataController->SetViewImpl(pWidget);
    m_spViewDataController->SetAdapter(m_spTableViewDataRefNodeAdapter.get());
    m_spViewDataController->Show();
}

void MainWindow::on_m_treeView_menuAction_triggered()
{
    CTreeViewWithCustomWidget *pWidget = new CTreeViewWithCustomWidget();
    setCentralWidget(pWidget);
}

void MainWindow::on_m_graphicsView_menuAction_triggered()
{
    CPaintBoardWidget *pWidget = new CPaintBoardWidget();
    setCentralWidget(pWidget);
}

void MainWindow::on_m_tab_menuAction_triggered()
{
    CStyledTabWidget *pWidget = new CStyledTabWidget();
    setCentralWidget(pWidget);
}

void MainWindow::on_m_button_menuAction_triggered()
{
    CButtonContainerWidget *pWidget = new CButtonContainerWidget();
    setCentralWidget(pWidget);
}

void MainWindow::on_m_lineedit_menuAction_triggered()
{
    CLineEditContainerWidget *pWidget = new CLineEditContainerWidget();
    setCentralWidget(pWidget);
}
